// pages/togroupinto/togroupinto.js
const app = getApp();
var ea = require('../../utils/each.js');
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    headsrc: app.data.imgurl +"headimg.png",
    getmyhuiyuaninfo: app.data.url + 'sheyingjia/Xhuiyuan1/getmyhuiyuaninfo',
    addtuanduizhanghu: app.data.url + 'sheyingjia/Xhuiyuan1/addtuanduizhanghu',
    jiaohuifeituandui: app.data.url + 'sheyingjia/Xhuiyuan1/jiaohuifeituandui',
    shuju: {},//获取会员信息
    users: {},//我的个人信息
    system:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var user = wx.getStorageSync('user');
    var that = this;
    ea.qinqiu(that.data.getmyhuiyuaninfo, { token: user.token }, function (data) {
      console.log(data);
      var shuju = data.data;
      var system = data.system;
      WxParse.wxParse('article', 'html', data.soufei.tuandui.jianjie, that, 25);
      if (shuju.length == 0) {
        wx.showToast({
          title: '你还没有申请会员',
          icon: 'none'
        })
        setTimeout(function () {
          wx.navigateBack({
            delta: 1
          })
        }, app.data.times)
      }
      var user = data.user;
      that.setData({ shuju: shuju, users: user,system:system });
      if (shuju.huiyuan != 2) {
        wx.showToast({
          title: '你申请的是个人会员',
          icon: 'none'
        })
      }

    })
  },
  //填写数据
  tianxie:function(e){
    // console.log(e);
    var type = e.currentTarget.dataset.type;
    var value = e.detail.value;
    var shuju = this.data.shuju;
    shuju[type] = value;
    console.log(shuju);
    this.setData({shuju:shuju});
  },
  //缴纳会费
  jiaonahuifei:function(){
    var user = wx.getStorageSync('user');
    var that = this;
    var shuju = this.data.shuju;
    ea.qinqiu(that.data.addtuanduizhanghu,{shuju:shuju,token:user.token},function(data){
      wx.showModal({
        title: '提示',
        content: '请通过对公账户打款',
      })
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})